package javase.homework.first;

import java.util.HashSet;
import java.util.Iterator;

public class Student {
	private int sid;
	private String name;
	private HashSet<Course> courses=new HashSet<Course>();
	
	public Student(String name, HashSet<Course> courses) {
		this.name = name;
		this.courses = courses;
	}
	public Student(int sid, String name, HashSet<Course> courses) {
		this.sid = sid;
		this.name = name;
		this.courses = courses;
	}
	public Student() {
	}
	public int getSid() {
		return sid;
	}
	public void setSid(int sid) {
		this.sid = sid;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public HashSet<Course> getCourses() {
		return courses;
	}
	public void setCourses(HashSet<Course> courses) {
		this.courses = courses;
	}
	
	public void addCourse(Course c){
		courses.add(c);
	}
	public void removeCourse(String name){
		Iterator<Course> it=courses.iterator();
		while(it.hasNext()){
			Course course=it.next();
			if(course.getName().equals(name)){
				courses.remove(course);
			}
		}
	}
	
}
